<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
    <head>
        
         <meta name="_csrf" th:content="${_csrf.token}"/>
    	 <meta name="_csrf_hader" th:content="${_csrf.headerName}"/>
    	 <title>Hello World!</title>
         <script th:src="@{/js/jquery.min.js}" type="text/javascript"></script>
    </head>
    <body>
        <h1 th:inline="text">Hello [[${#httpServletRequest.remoteUser}]]!</h1>
      	<input th:type="submit" onclick="testPost()" th:value="前往管理员页面"/>
        <form th:action="@{/logout}" method="post">
            <input type="submit" value="Sign Out"/>
        </form>
        
    </body>
    <script>
    function testPost() {
        var token = $('meta[name="_csrf"]').attr("content");
        var header = $('meta[name="_csrf_hader"]').attr("content");
        $(document).ajaxSend(function(e,xhr,opt){
            xhr.setRequestHeader(header,token);
        });
        $.ajax({
            url:"/admin",
            type:'POST',

            success:function (data) {

            }
        });
    }
</script>
</html>